package com.db.stockexchange.common;

public enum OrderStatus {
	NEW("0"), PARTIALLY_FILLED("1"), FILLED("2"), CANCELLED("4"), REJECTED("8");

	private String status;
	
	private OrderStatus(String status) {
		this.status = status;
	}
	
	public static OrderStatus fromString(String status) {
		switch (status) {
		case "0": return NEW;
		case "1": return PARTIALLY_FILLED;
		case "2": return FILLED;
		case "4": return CANCELLED;
		case "8": return REJECTED;
		default:
			throw new IllegalArgumentException("Illegal order status");
		}
	}
	
	public String asString() {
		return status;
	}
	
}
